//
//  ShopView.m
//  afn
//
//  Created by mac on 2018/5/7.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "ShopView.h"
#import "ShopTableViewCell.h"

@implementation ShopView

-(void)creatView{
    _tableView=[BaseTableView new];
    [self addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(0);
    }];
    _tableView.backgroundColor=_LightGrey;
    _tableView.delegate=self;
    _tableView.dataSource=self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ShopTableViewCell *cell=[[ShopTableViewCell alloc] init];
    cell.fuWuArr=_fuWuArr;
    cell.model=_model;
    cell.barBerArr=_barBerArr;
    cell.shop_service=_shop_service;
    cell.talkArr=_talkArr;
    cell.viewController=self.viewController;
    if (indexPath.row==0) {
       [cell creatView];
    }
    if (indexPath.row==1) {

        cell.num=_num;
        [cell setFrame:CGRectMake(0, 0, _mainW, [cell creatView2])];
            __weak typeof(self) weakSelf = self;
            cell.customSelectedBlock = ^ (NSNumber *abc)
            {
                weakSelf.num=abc;
                NSIndexPath *indexPath=[NSIndexPath indexPathForRow:1 inSection:0];
                [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
            };
    }
    if (indexPath.row==2) {
       [cell creatView3];
    }
    if (indexPath.row==3) {
        [cell setFrame:CGRectMake(0, 0, _mainW, [cell creatView4])];
        
    }
    if (indexPath.row==4) {
        [cell setFrame:CGRectMake(0, 0, _mainW, [cell creatView5])];
        
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0) {
        return 240;
    }
    if (indexPath.row==1||indexPath.row==3||indexPath.row==4) {
            UITableViewCell *cell;
            cell= [self tableView:tableView cellForRowAtIndexPath:indexPath];
            return cell.frame.size.height;
    } if (indexPath.row==2) {
        return 170;
    }
   

    return 0;
    
}

@end
